import { FetchDevice } from "../common/InitGPU";
import { create3DFVertices } from "webgpu-utils/dist/1.x/webgpu-utils.js";

async function init() {
    const device =await FetchDevice();

    const module=device.createShaderModule({
        label:'triangle shaders with uniforms',
        code:`
            struct OurStruct {
                color: vec4f,
                scale: vec2f,
                offset: vec2f
            };

            @group(0) @binding(0) var<uniform> ourStruct: OurStruct;
            @vertex fn vs(
                @builtin(vertex_index) vertexIndex : u32
            ) -> @builtin(position) vec4f {
                let pos = array(
                    vec2f(0.0,0.5), vec2f(-0.5,-0.5), vec2f(0.5,-0.5)
                );

                return vec4f(pos[vertexIndex]*ourStruct.scale+ourStruct.offset,0.0,1.0);
            }

            @fragment fn fs() -> @location(0) vec4f {
                return ourStruct.color;
            }
        `
    })
}